﻿@model  List<HomeCareLibrary.Core.Dtos.CRC_Task_DetailsDto>


@{
    ViewBag.Title = "Add";
}

<div class="col-lg-9 col-sm-9 right_part CRCCustomPage">
    <div class="additional-web-pages CustomTask2-Page personalization-page">


        @if (Session[HomeCareLibrary.Constants.SessionConstants.MODE] == null || Session[HomeCareLibrary.Constants.SessionConstants.MODE].ToString() == HomeCareLibrary.Constants.ApplicationModeConstants.IPHONE_APP || Session[HomeCareLibrary.Constants.SessionConstants.MODE].ToString() == HomeCareLibrary.Constants.ApplicationModeConstants.IPAD_APP)
        {
            <div class="title clearfix">
                <h1>Custom Tasks</h1>
                <div class="top-btn-per clearfix">
                    <div id="back-button" class="back-button">
                        <a href="javascript:void(0);">
                            <img class="back-btn" alt="back-btn" src="@Url.Content("~/images/personalization-images/back-btn.png")">

                            <div class="back-mob-btn"><span class="glyphicon glyphicon-chevron-left"></span>Back</div>
                        </a>
                    </div>
                    <div class="ques-button">
                        <a id="btnAdd" href="javascript:void(0);">
                            <img src="@Url.Content("~/images/customTask-img/plus sign.png")" alt="">
                        </a>

                    </div>
                </div>
            </div>
        }
        @{
                  var sessionValue = "";
                  if (Session[HomeCareLibrary.Constants.SessionConstants.MODE]!=null)
                  {
                      sessionValue = Session[HomeCareLibrary.Constants.SessionConstants.MODE].ToString();
                  }
                  else{
                      sessionValue = "";
                  }
                      <input type="hidden" value="@sessionValue" id="hdnSessionValue" />
              }

        @{var androidContent = string.Empty;
          if (Session[HomeCareLibrary.Constants.SessionConstants.MODE] == null || Session[HomeCareLibrary.Constants.SessionConstants.MODE] == HomeCareLibrary.Constants.ApplicationModeConstants.IPHONE_APP || Session[HomeCareLibrary.Constants.SessionConstants.MODE] == HomeCareLibrary.Constants.ApplicationModeConstants.IPAD_APP)
          {
              androidContent = "class= personalization-content";
          }
          else
          {
              androidContent = "";
          }
        }

        @*<div class="ques-button" style="margin-top:10px;margin-right:10px;"><a href="#">
                <img class="ques-bt" alt="ques-btn" src="@Url.Content("~/images/customTask-img/plus sign.png")">
<img class="mobques-bt" alt="ques-btn" src="@Url.Content("~/images/customTask-img/plus sign.png")">
                </a></div>*@




        <div class="main-content">
            <div class="personalization-content">
                <div class="personalization-bg">
                    <div class="white-box">


                        <div class="personalization-inn">
                           

                                @if (ViewBag.getSingleHomeName != null && ViewBag.getSingleHomeName != "")
                                {
                               <span class="homeNumber-list"> @ViewBag.getSingleHomeName</span>
             
            
                                }
                                else
                                {
                                    using (Html.BeginForm("Add", "CustomTasks", FormMethod.Post, new { enctype = "multipart/form-data" }))
                                    {
                                @Html.DropDownList("getHomeName", null, new
                           {
                               @class = "form-control homeNumber-list",
                               disableValidation = "true",
                               onchange = @"                        
                form.submit();"
                           })
                                    }
                                <input type="hidden" name="getSingleHomeName" id="getSingleHomeName" value="@ViewBag.getSingleHomeValue" />
      
       

                
                                }

                            @if (Model != null && Model.Count() > 0)
                            {
                      
                                <div class="personalization-data custom-task2-additional">
                                    <div class="group-mtt-outer">
                                        @foreach (var item in Model)
                                        {
                                            <div class="panel-group-mtt clearfix">

                                                <div class="media">
                                                    <a class="ACR-img" href="#">
                                                        @if (item.image != null)
                                                        {
                                                            <img alt="@item.image" src="@Url.Content("~/" + item.image)"> 
                                                        }

                                                    </a>
                                                    <div class="media-body">
                                                        <div class="left-group-panel">
                                                            <h4 class="media-heading">@item.feature_name</h4>
                                                            <div class="icon-mtt clearfix">
                                                                <div class="star pull-left">
                                                                    @if (item.priority != null)
                                                                    {
                                                                        <img alt="star-i3" src="@Url.Content("~/images/mtt-images/" + item.priority + "_star.png")">
                                                                    }
                                                                </div>
                                                                <div class="plug-icon"><a href="#">
                                                                    <img alt="plug-icon.png" src="@Url.Content("~/images/mtt-images/plug-icon.png")"></a></div>
                                                                <div class="arrow-icon">

                                                                    <a href="javascript:void(0);" class="crcTaskDetail" data-taskCode="@item.task_code">
                                                                        <img alt="arrow-img" src="@Url.Content("~/images/mtt-images/arrow-img.png")" class="img-responsive">
                                                                    </a>

                                                                </div>
                                                            </div>
                                                            <p>@item.task_description</p>
                                                        </div>

                                                    </div>
                                                </div>

                                            </div>
                                        }
                                    </div>
                                </div>


                     

                            }
                            else
                            {
                                <div class="personalization-data custom-task-additional">



                                    <p class="top-data-img" style="text-align: center;">
                                        <img src="@Url.Content("~/images/additional-pages-images/custom-task-img.jpg")" alt="" /></p>
                                    <p class="top-data" style="text-align: center;">
                                        <strong>You currently have no Custom Tasks.</strong><br />
                                        You can create new Custom Tasks by clicking the plus sign above.<br />
                                        Or you can modify existing tasks from their Task Details screens.
                      
                     
                                </div>
                            }
                            <br />
                            <br />


                            Session Ids with values:
                      @if (ViewBag.sessionIds != string.Empty)
                      {
                          @ViewBag.sessionIds
                      }
                            <br />



                            <br />
                            <span style="margin-left: 10px;">Session:
                    @if (ViewBag.getSession != string.Empty)
                    {
                        @ViewBag.getSession
                    }
                            </span>

                            <br />

                            <span style="margin-left: 10px;">JSON:
                    @if (ViewBag.JsonString != string.Empty)
                    {
                        @ViewBag.JsonString
                    }</span>

                            <br />
                            <br />
                            <span>Request Content-Type:
                    @if (ViewBag.ContentType != string.Empty)
                    {
                        @ViewBag.ContentType
                    }
                            </span>

                            <br />
                            <br />
                            <span>Request URL:
                    @if (ViewBag.Url != string.Empty)
                    {
                        @ViewBag.Url
                    }
                            </span>

                            <br>
                            <br>
                            <br>
                            <br>
                            <br>
                            <br>
                            <br>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
  <div id="taskDetailCRC" style="display:none;"></div>
            <!----------------------------------
           End
            -------------------------------->
            
           

<script>
    $(function () {
        $("#imgTaskCustomize").attr("src", "/" + $("#imgTaskIamge").attr('alt'));
        $("#titleTaskCustomize").html($("#taskTitle").html());
        $(".titleFeature").html($("#taskTitle").html());
        $("#descriptionTaskCustomize").html($("#taskDescription").html());
        $("#imgPriorityTaskCustomize").attr("src", "/images/detail-page-img/star" + $("#imgPriority").attr("data-priority") + "-d.png");

        var $window = $(window);
        var windowsize = $window.width();
        
        if (windowsize < 767) {
           
            $(".mobileMenu").show();
        }
        checkForIphone();
    });

    function checkForIphone() {

        if ($("#hdnSessionValueTask").val() != '') {
            if ($("#hdnSessionValueTask").val() == "@HomeCareLibrary.Constants.ApplicationModeConstants.IPHONE_APP") {

                $(".mobileMenu").hide();
            }
        }

    }
    </script>
@section script {

    <script src="@Url.Content("~/js/iPhone/IPhoneExtras.js")"></script>
    <script>
        $("#getHomeName").change(function () {
            $.ajax({
                type: "POST",
                url: "/CustomTasks/Add",
                data: { "homeNumber": $(this).val() },
                success: function (data) {
                    if (data == "") {
                        window.location.href = "/home/login"
                        return false;
                    }


                },
                error: function (xhr, ajaxOptions, thrownError) {
                    $("#wait_tasktipsideas").css("display", "none");
                    alert('Failed to retrieve states.');
                }


            });
        });
        $(".crcTaskDetail").live("click", function () {
            $("#wait_tasktipsideas").css("display", "block");
            $.ajax({
                type: "POST",
                url: "/CustomTasks/TaskDetail",
                data: { "taskCode": $(this).attr("data-taskCode") },
                success: function (data) {
                    if (data == "") {
                        window.location.href = "/home/login"
                        return false;
                    }
                    $(".CRCCustomPage").hide();
                    $("#taskDetailCRC").html(data);
                    $("#taskDetailCRC").show();
                    $("#wait_tasktipsideas").css("display", "none");
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    $("#wait_tasktipsideas").css("display", "none");
                    alert('Failed to retrieve states.');
                }
            });
        });
    </script>
}
